/**
 * AssessPlayerItem
 * @Author ace.ch
 * @Date 2018/3/28 19:50
 */
class AssessPlayerItem extends BaseSprite {

    head: HeadIcon;
    lab_nick: eui.Label;
    img_thumbs: eui.Image;

    constructor() {
        super();

        this.skinName = 'AssessPlayerItemSkin';
    }

    childrenCreated() {
        super.childrenCreated();

        this.clean();
    }

    update(data: any) {
        this.skinState = 'normal';

        this.data = data;

        this.head.src = data.zan == 1 ? "assess" : "unassess";
        this.head.isVip = data.hasOwnProperty('gid');
        this.lab_nick.text = '' + data.nick;
        this.comment = data.zan;
    }

    clean() {
        this.skinState = 'empty';

        this.owner = false;
    }

    set owner(b: boolean) {
        this.head.isOwner = b;
    }

    get comment(): number {
        return this.data ? this.data.zan : 0;
    }

    set comment(v: number) {
        this.img_thumbs.source = v == 1 ? "assess_ico_good_1" : "assess_ico_bad_1";
        this.data.zan = v;
    }

    set commentB(v: number) {
        this.img_thumbs.source = v == 1 ? "assess_ico_good_2" : "assess_ico_bad_2";
        this.data.zan = v;
    }
}